/**
 * 公共组件弹框
 */
import React from 'react';
import { Modal } from 'antd';
// import { Util, } from 'tools/index';
// import asyncComponent from '../../../routers/AsyncComponent.js';
import CaseInformationPage from './CaseInformationPage';
import CaseInformationPageHospital from './CaseInformationPageHospital';
import '../style/index.less';

class ShowMedicalRecordModal extends React.Component {
  constructor(props) {
    super(props);
    var userData = JSON.parse(sessionStorage.getItem('userData'));
    this.state = {
      userData: userData,
    }
  }
  //   componentWillReceiveProps(nextProp) {
  //     if (nextProp.isShow === true) {
  //       this.setState({
  //         component: nextProp.dataSource.component
  //       })
  //     } else if (this.props.isShow === false) {

  //     }
  //   }


  closeModal(name) {
    let { onHide } = this.props;
    onHide && onHide();
  }

  render() {
    const { modalTitle } = this.props;
    // const Component = asyncComponent(() => import('../../../' + this.state.component));
    // modal 是否弹框标记
    return <div>
      <Modal className='medical-component-modal'
        title={modalTitle || (this.props.admTypeCode == 'O' ? '门诊病历' : '住院病历')}
        maskClosable={false}
        visible={this.props.isShow}
        onCancel={this.closeModal.bind(this)}
        footer={null}
      >
        {/* <Component modal="1" /> */}
        {
          this.props.admTypeCode == 'O' ? (
            <CaseInformationPage
              fGroupTempByInfo="previewEMRRec"
              fGroup="previewEMRRec"
              isDidUpdate="Y"
              editorID="SMRWriterControl"
              caseInformationPageTabs="N"
              clpHeader="80vh"
              viewEMRFlag={this.props && 'viewEMRFlag' in this.props ? this.props.viewEMRFlag : 'N'}
              initTemplate={this.props && 'initTemplate' in this.props ? this.props.initTemplate : 'N'}
              isBasicOperation={this.props && 'isBasicOperation' in this.props ? this.props.isBasicOperation : true}
              historyAdmID={this.props && this.props.historyAdmID ? this.props.historyAdmID : ""}
              isOperable={this.props && 'isOperable' in this.props ? this.props.isOperable : 'Y'}
              prCont={this.props && 'prCont' in this.props ? this.props.prCont : 'N'}
            />
          ) : <CaseInformationPageHospital
            isDidUpdate="Y"
            clpHeader="80vh"
            fGroup="previewEMRRec"
            caseInformationPageTabs="N"
            editorID="SMRWriterControlHospital"
            viewEMRFlag={this.props && 'viewEMRFlag' in this.props ? this.props.viewEMRFlag : 'N'}
            initTemplate={this.props && 'initTemplate' in this.props ? this.props.initTemplate : 'N'}
            isBasicOperation={this.props && 'isBasicOperation' in this.props ? this.props.isBasicOperation : true}
            historyAdmID={this.props && this.props.historyAdmID ? this.props.historyAdmID : ""}
            isOperable={this.props && 'isOperable' in this.props ? this.props.isOperable : 'Y'}
            prCont={this.props && 'prCont' in this.props ? this.props.prCont : 'N'}
          />
        }
      </Modal>
    </div>
  }
}

export default ShowMedicalRecordModal;